﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using aucn.web.au.code;

namespace aucn.web.au
{
    public partial class Facilities : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Master.Attributes["submenu"] = "Facility";

            string facid = Request.QueryString["f"] == null ? "BLDG" : Request.QueryString["f"].Trim().ToUpper();
            Facility f = Facility.FromXml(facid);
            if (f == null)
            {
                f = Facility.FromXml("BLDG");
            }

            if (f != null)
            {
                FormView1.DataBound += new EventHandler(FormView1_DataBound);
                this.BindData(f);
            }
        }

        void FormView1_DataBound(object sender, EventArgs e)
        {
            Repeater rptr = (Repeater)FormView1.Row.FindControl("Repeater1");
            Facility f = (Facility)FormView1.DataItem;
            rptr.DataSource = f.ImageList;
            rptr.DataBind();
        }

        protected void BindData(Facility f)
        {
                this.Title += " : " + f.FacilityName;
                List<Facility> f1 = new List<Facility>();
                f1.Add(f);
                FormView1.DataSource = f1;
                FormView1.DataBind();
        }
    }
}
